// http://www.manongjc.com/detail/51-fgnqcbzgleqgbfs.html   富文本解析插件
import { LABEL } from "../../../config/base.js";
const mRequest = require('../../../utils/api.js')
Page({
  data: {
    adList:'',
    detailData: '',
    label: LABEL,
    isImg: '',
    img: 'https://cdn.seovx.com/d/?mom=302',
  },


  clientDetail:function(){
    var that = this
    var Base64 = require('../../../utils/base64.modified.js');
    // console.log(Base64.encode('微信小程序'));  // base64加密
    // console.log(Base64.decode('5b6u5L+h5bCP56iL5bqP'));  // base64解密
    var params ={path:that.options.path,access_token:wx.getStorageSync('access_token')}
    mRequest.getList(params).then(res => {
      if (res.length == 0) {
        wx.showToast({
          title: '数据为空' + res.msg,
          icon: 'error',
          duration: 2000
        });
      } else {
        if (res.path.includes("jpg")){
          that.setData({
            adList:res,
            isImg: true
          })
        } else {
          that.setData({
            adList:res,
            detailData:Base64.decode(res.content),
            isImg: false
          })
        }
      }
    }).catch(err => {
      console.log('error: ', err);
    })
  },


onCopy(){
  var that = this;
  wx.setClipboardData({
    data: that.data.adList.download_url,
    success(res){
      wx.showToast({
        title: '复制成功',
      })
    }
  })
},

 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.clientDetail()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})